#include "GUIConstruction.h"
#include "IRenderer.h"

#define TOOLBOX_LOCATION		0, 0
#define TOOLBOX_DIMENSIONS		100, 250

#define PROPERTIES_DIMENSIONS	160, Renderer->getWindowHeight()
#define PROPERTIES_LOCATION		Renderer->getWindowWidth()-160, 0
#define PROPERTIES_DOCKING		GUIWindow::RIGHT | GUIWindow::TOPBOTTOM

void GUIEditorToolboxConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<GUIWindow> toolbox = new GUIWindow();
	gameEditor->wndToolbox = toolbox;
	Pointer<IGUIElement> element;
	toolbox->Dimensions(Maths::Point<unsigned int>(100, 250));
	toolbox->Location(Maths::Point<unsigned int>(0, 0));
	toolbox->FontColor(0xFF00FF00);
	toolbox->Title(std::string("Toolbox"));

	GUIButton* button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 10));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Create Entity"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CreateEntity)));
	toolbox->AddChild( button );

	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 30));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Load Model"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowLoadModelWindow)));
	toolbox->AddChild( button );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 50));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Create Terrain"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowCreateTerrainWindow)));
	toolbox->AddChild( button );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 70));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("SceneGraph"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowSceneGraphWindow)));
	toolbox->AddChild( button );

	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 90));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Create Light"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CreateLight)));
	toolbox->AddChild( button );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 110));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Save State"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowSaveStateWindow)));
	toolbox->AddChild( button );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 130));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Load State"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowLoadStateWindow)));
	toolbox->AddChild( button );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 150));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Show Entities"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowEntitiesWindow)));
	toolbox->AddChild( button );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 170));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Load Texture"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowLoadTextureWindow)));
	toolbox->AddChild( button );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 190));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Create AI"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CreateAI)));
	toolbox->AddChild( button );

	CopyPointer(toolbox, element);
	gui->AddElement(element);
	
	Renderer->getWindow()->RegisterHandler("OnMouseLeftDownEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(toolbox, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseLeftUpEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(toolbox, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(toolbox, &GUIWindow::ReceiveEvent) ));
}

void PositionMenuItem( Pointer<GUIMenu>& menu, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIMenuItem> item = new GUIMenuItem();
	item->FontColor(0xFF000000);
	item->Title(std::string("Position"));
	menu->AddMenuItem( item );

	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtPositionX = textbox;
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->Text(std::string("X"));
	CopyPointer(textbox, element);
	item->AddElement( element );
	
	textbox = new GUITextbox();
	gameEditor->txtPositionY = textbox;
	textbox->Location(Maths::Point<unsigned int>(56, 2));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->Text(std::string("Y"));
	CopyPointer(textbox, element);
	item->AddElement( element );

	textbox = new GUITextbox();
	gameEditor->txtPositionZ = textbox;
	textbox->Location(Maths::Point<unsigned int>(110, 2));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->Text(std::string("Z"));
	CopyPointer(textbox, element);
	item->AddElement( element );

	Pointer<GUIButton> button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(2, 24));
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Ok"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SetEntityPosition)));
	CopyPointer(button, element);
	item->AddElement( element );
}
void GraphicMenuItem( Pointer<GUIMenu>& menu, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIMenuItem> item = new GUIMenuItem();
	item->FontColor(0xFF000000);
	item->Title(std::string("Graphic"));
	menu->AddMenuItem( item );

	Pointer<GUIComboBox> combobox = new GUIComboBox();
	gameEditor->cmbModelName = combobox;
	combobox->Location(Maths::Point<unsigned int>(2, 2));
	combobox->Dimensions(Maths::Point<unsigned int>(80, 20));
	combobox->FontColor(0xFFFF0000);
	combobox->DefaultText(std::string("Model Name..."));
	CopyPointer(combobox, element);
	item->AddElement( element );
	
	Pointer<GUIButton> button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(2, 24));
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Ok"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SetEntityGraphic)));
	CopyPointer(button, element);
	item->AddElement( element );
}
void NameMenuItem( Pointer<GUIMenu>& menu, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIMenuItem> item = new GUIMenuItem();
	item->FontColor(0xFF000000);
	item->Title(std::string("Name"));
	menu->AddMenuItem( item );

	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtEntityName = textbox;
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->Dimensions(Maths::Point<unsigned int>(80, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Entity Name..."));
	CopyPointer(textbox, element);
	item->AddElement( element );
	
	Pointer<GUIButton> button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(2, 24));
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Ok"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SetEntityName)));
	CopyPointer(button, element);
	item->AddElement( element );
}
void RigidBodyMenuItem( Pointer<GUIMenu>& menu, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIMenuItem> item = new GUIMenuItem();
	item->FontColor(0xFF000000);
	item->Title(std::string("RigidBody"));
	menu->AddMenuItem( item );

	Pointer<GUIComboBox> combobox = new GUIComboBox();
	gameEditor->cmbRigidBodyTypes = combobox;
	combobox->Location(Maths::Point<unsigned int>(2, 2));
	combobox->Dimensions(Maths::Point<unsigned int>(100, 20));
	combobox->FontColor(0xFFFF0000);
	combobox->DefaultText(std::string("Rigidbody Shape"));
	combobox->AddItem(std::string("Sphere"));
	combobox->AddItem(std::string("BoundingSphere"));
	combobox->AddItem(std::string("Triangle Mesh"));
	CopyPointer(combobox, element);
	item->AddElement( element );
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtBodyPositionX = textbox;
	textbox->Location(Maths::Point<unsigned int>(2, 24));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Offset X"));
	CopyPointer(textbox, element);
	item->AddElement( element );
	
	textbox = new GUITextbox();
	gameEditor->txtBodyPositionY = textbox;
	textbox->Location(Maths::Point<unsigned int>(56, 24));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->Text(std::string("Offset Y"));
	CopyPointer(textbox, element);
	item->AddElement( element );

	textbox = new GUITextbox();
	gameEditor->txtBodyPositionZ = textbox;
	textbox->Location(Maths::Point<unsigned int>(110, 24));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Offset Z"));
	CopyPointer(textbox, element);
	item->AddElement( element );

	Pointer<GUIButton> button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(2, 44));
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Ok"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::AddRigidbodyShape)));
	CopyPointer(button, element);
	item->AddElement( element );
	
	button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(84, 44));
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Show Shapes"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowRigidBodyShapes)));
	CopyPointer(button, element);
	item->AddElement( element );
}
void SelectableMenuItem( Pointer<GUIMenu>& menu, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIMenuItem> item = new GUIMenuItem();
	item->FontColor(0xFF000000);
	item->Title(std::string("Selectable Body"));
	menu->AddMenuItem( item );

	Pointer<GUIComboBox> combobox = new GUIComboBox();
	gameEditor->cmbSelectableBodyTypes = combobox;
	combobox->Location(Maths::Point<unsigned int>(2, 2));
	combobox->Dimensions(Maths::Point<unsigned int>(100, 20));
	combobox->FontColor(0xFFFF0000);
	combobox->DefaultText(std::string("Rigidbody Shape"));
	combobox->AddItem(std::string("Sphere"));
	combobox->AddItem(std::string("BoundingSphere"));
	combobox->AddItem(std::string("Triangle Mesh"));
	CopyPointer(combobox, element);
	item->AddElement( element );
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtSelectableBodyPositionX = textbox;
	textbox->Location(Maths::Point<unsigned int>(2, 24));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Offset X"));
	CopyPointer(textbox, element);
	item->AddElement( element );
	
	textbox = new GUITextbox();
	gameEditor->txtSelectableBodyPositionY = textbox;
	textbox->Location(Maths::Point<unsigned int>(56, 24));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->Text(std::string("Offset Y"));
	CopyPointer(textbox, element);
	item->AddElement( element );

	textbox = new GUITextbox();
	gameEditor->txtSelectableBodyPositionZ = textbox;
	textbox->Location(Maths::Point<unsigned int>(110, 24));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Offset Z"));
	CopyPointer(textbox, element);
	item->AddElement( element );

	Pointer<GUIButton> button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(2, 44));
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Ok"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::AddSelectablebodyShape)));
	CopyPointer(button, element);
	item->AddElement( element );
	
	button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(84, 44));
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Show Shapes"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowSelectableBodyShapes)));
	CopyPointer(button, element);
	item->AddElement( element );
}
void ControllerMenuItem( Pointer<GUIMenu>& menu, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIMenuItem> item = new GUIMenuItem();
	gameEditor->mitController = item;
	item->FontColor(0xFF000000);
	item->Title(std::string("Controller"));
	item->Visible(false);
	menu->AddMenuItem( item );

	Pointer<GUIButton> button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(2, 2));
	button->Dimensions(Maths::Point<unsigned int>(130, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Show Controller Window"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowControllerWindow)));
	CopyPointer(button, element);
	item->AddElement( element );
}
void GUIEntityMenu( Pointer<GUIWindow>& properties, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIMenu> menu = new GUIMenu();
	gameEditor->mnuEntityProperties = menu;
	menu->Location(Maths::Point<unsigned int>(0, 0));
	menu->FontColor(0xFFFFFFFF);
	menu->Title(std::string(""));
	menu->Visible(false);

	CopyPointer(menu, element);
	properties->AddChild( element );

	PositionMenuItem(menu, gameEditor);
	GraphicMenuItem(menu, gameEditor);
	NameMenuItem(menu, gameEditor);
	RigidBodyMenuItem(menu, gameEditor);
	SelectableMenuItem(menu, gameEditor);
	ControllerMenuItem(menu, gameEditor);
}
void GUILightMenu( Pointer<GUIWindow>& properties, GameEditorGUI* gameEditor )
{
	// Menu
	Pointer<IGUIElement> element;
	Pointer<GUIMenu> menu = new GUIMenu();
	gameEditor->mnuLightProperties = menu;
	menu->Location(Maths::Point<unsigned int>(0, 0));
	menu->FontColor(0xFFFFFFFF);
	menu->Title(std::string(""));
	menu->Visible(false);

	CopyPointer(menu, element);
	properties->AddChild( element );

	Pointer<GUIMenuItem> item = new GUIMenuItem();
	item->FontColor(0xFF000000);
	item->Title(std::string("Position"));
	menu->AddMenuItem( item );

	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtLightPositionX = textbox;
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("X"));
	CopyPointer(textbox, element);
	item->AddElement( element );
	
	textbox = new GUITextbox();
	gameEditor->txtLightPositionY = textbox;
	textbox->Location(Maths::Point<unsigned int>(56, 2));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Y"));
	CopyPointer(textbox, element);
	item->AddElement( element );

	textbox = new GUITextbox();
	gameEditor->txtLightPositionZ = textbox;
	textbox->Location(Maths::Point<unsigned int>(110, 2));
	textbox->Dimensions(Maths::Point<unsigned int>(50, 20));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Z"));
	CopyPointer(textbox, element);
	item->AddElement( element );

	Pointer<GUIButton> button = new GUIButton();
	button->Location(Maths::Point<unsigned int>(2, 24));
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Ok"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SetLightPosition)));
	CopyPointer(button, element);
	item->AddElement( element );
}

void GUIPropertiesConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;

	Pointer<GUIWindow> properties = new GUIWindow();
	gameEditor->wndProperties = properties;
	properties->Dimensions(Maths::Point<unsigned int>(PROPERTIES_DIMENSIONS));
	properties->Location(Maths::Point<unsigned int>(PROPERTIES_LOCATION));
	properties->FontColor(0xFF00FF00);
	properties->Title(std::string("Properties"));
	properties->Dock(PROPERTIES_DOCKING);
	//properties->EnterFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SetPosition)));

	//Pointer<GUILabel> label = new GUILabel();
	//label->Dimensions(Maths::Point<unsigned int>(50, 20));
	//label->Location(Maths::Point<unsigned int>(2, 10));
	//label->FontColor(0xFFFF0000);
	//label->Text(std::string("Position:"));
	//CopyPointer(label, element);
	//properties->AddChild( element );
	
	GUIEntityMenu( properties, gameEditor );
	GUILightMenu( properties, gameEditor );
	
	CopyPointer(properties, element);
	gui->AddElement(element);

	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(properties, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(properties, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(properties, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnWindowResizeEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(properties, &GUIWindow::ReceiveEvent) ));
}
void GUILoadModelWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> loadModel = new GUIWindow();
	gameEditor->wndLoadModel = loadModel;
	loadModel->Visible(false);
	loadModel->Dimensions(Maths::Point<unsigned int>(200, 80));
	loadModel->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	loadModel->FontColor(0xFF00FF00);
	loadModel->Title(std::string("Load Model"));
	loadModel->EnterFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::LoadModel)));
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtModelFileName = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Model File Name..."));
	CopyPointer(textbox, element);
	loadModel->AddChild( element );
	
	Pointer<GUIButton> button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(2, 24));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Load Model"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::LoadModel)));
	CopyPointer(button, element);
	loadModel->AddChild( element );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(86, 24));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Cancel"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CancelLoadModel)));
	CopyPointer(button, element);
	loadModel->AddChild( element );
	
	CopyPointer(loadModel, element);
	gui->AddElement(element);

	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadModel, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadModel, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadModel, &GUIWindow::ReceiveEvent) ));
}
void GUISaveStateWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> unloadState = new GUIWindow();
	gameEditor->wndSaveState = unloadState;
	unloadState->Visible(false);
	unloadState->Dimensions(Maths::Point<unsigned int>(200, 80));
	unloadState->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	unloadState->FontColor(0xFF00FF00);
	unloadState->Title(std::string("Save State"));
	unloadState->EnterFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SaveState)));
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtSaveStateFileName = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("File Name..."));
	CopyPointer(textbox, element);
	unloadState->AddChild( element );
	
	Pointer<GUIButton> button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(2, 24));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("OK"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SaveState)));
	CopyPointer(button, element);
	unloadState->AddChild( element );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(86, 24));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Cancel"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CancelSaveState)));

	CopyPointer(button, element);
	unloadState->AddChild( element );
	
	CopyPointer(unloadState, element);
	gui->AddElement(element);

	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(unloadState, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(unloadState, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(unloadState, &GUIWindow::ReceiveEvent) ));
}
void GUILoadStateWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> loadState = new GUIWindow();
	gameEditor->wndLoadState = loadState;
	loadState->Visible(false);
	loadState->Dimensions(Maths::Point<unsigned int>(200, 80));
	loadState->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	loadState->FontColor(0xFF00FF00);
	loadState->Title(std::string("Load State"));
	loadState->EnterFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::LoadState)));
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtLoadStateFileName = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("File Name..."));
	CopyPointer(textbox, element);
	loadState->AddChild( element );
	
	Pointer<GUIButton> button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(2, 24));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("OK"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::LoadState)));
	CopyPointer(button, element);
	loadState->AddChild( element );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(86, 24));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Cancel"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CancelLoadState)));
	CopyPointer(button, element);
	loadState->AddChild( element );
	
	CopyPointer(loadState, element);
	gui->AddElement(element);

	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadState, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadState, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadState, &GUIWindow::ReceiveEvent) ));
}
void GUILoadTextureWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> loadTexture = new GUIWindow();
	gameEditor->wndLoadTexture = loadTexture;
	loadTexture->Visible(false);
	loadTexture->Dimensions(Maths::Point<unsigned int>(200, 80));
	loadTexture->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	loadTexture->FontColor(0xFF00FF00);
	loadTexture->Title(std::string("Load Texture"));
	loadTexture->EnterFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::LoadTexture)));
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtTextureFileName = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Image File Name..."));
	CopyPointer(textbox, element);
	loadTexture->AddChild( element );
	
	Pointer<GUIButton> button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(2, 24));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Load Texture"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::LoadTexture)));
	CopyPointer(button, element);
	loadTexture->AddChild( element );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(86, 24));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Cancel"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CancelLoadTexture)));
	CopyPointer(button, element);
	loadTexture->AddChild( element );
	
	CopyPointer(loadTexture, element);
	gui->AddElement(element);

	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadTexture, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadTexture, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(loadTexture, &GUIWindow::ReceiveEvent) ));
}
void GUICreateTerrainWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> createTerrain = new GUIWindow();
	gameEditor->wndCreateTerrain = createTerrain;
	createTerrain->Visible(false);
	createTerrain->Dimensions(Maths::Point<unsigned int>(200, 130));
	createTerrain->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	createTerrain->FontColor(0xFF00FF00);
	createTerrain->Title(std::string("Create Terrain"));
	createTerrain->EnterFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CreateTerrain)));
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtTerrainHeightmapFileName = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Heightmap File Name..."));
	CopyPointer(textbox, element);
	createTerrain->AddChild( element );
	
	textbox = new GUITextbox();
	gameEditor->txtTerrainName = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 24));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Terrain Name..."));
	CopyPointer(textbox, element);
	createTerrain->AddChild( element );
	
	textbox = new GUITextbox();
	gameEditor->txtTerrainPixelStep = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(80, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 46));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Pixel step..."));
	CopyPointer(textbox, element);
	createTerrain->AddChild( element );
	
	textbox = new GUITextbox();
	gameEditor->txtTerrainTextures = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 68));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("Textures... (';' delimiter)"));
	CopyPointer(textbox, element);
	createTerrain->AddChild( element );

	Pointer<GUIButton> button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(2, 90));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Create Terrain"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CreateTerrain)));
	CopyPointer(button, element);
	createTerrain->AddChild( element );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(86, 90));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Cancel"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CancelCreateTerrain)));
	CopyPointer(button, element);
	createTerrain->AddChild( element );
	
	CopyPointer(createTerrain, element);
	gui->AddElement(element);

	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(createTerrain, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(createTerrain, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(createTerrain, &GUIWindow::ReceiveEvent) ));
}
void GUISelectableBodyWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> selectablebodyDisplay = new GUIWindow();
	gameEditor->wndSelectableBodyDisplay = selectablebodyDisplay;
	selectablebodyDisplay->Visible(false);
	selectablebodyDisplay->Dimensions(Maths::Point<unsigned int>(200, 130));
	selectablebodyDisplay->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	selectablebodyDisplay->FontColor(0xFF00FF00);
	selectablebodyDisplay->Title(std::string("Selectable Shapes"));
	
	Pointer<GUIButton> ptrbutton = new GUIButton();
	gameEditor->btnSelectableBodyDelete = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(2, 0));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Delete"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::DeleteSelectableBodyShape)));
	
	CopyPointer(ptrbutton, element);
	selectablebodyDisplay->AddChild( element );
	
	ptrbutton = new GUIButton();
	gameEditor->btnSelectableBodyCancel = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(64, 0));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Cancel"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::HideSelectableBodyShapes)));
	
	CopyPointer(ptrbutton, element);
	selectablebodyDisplay->AddChild( element );
	
	ptrbutton = new GUIButton();
	gameEditor->btnSelectableBodyDeleteAll = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(126, 0));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Delete All"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::DeleteAllSelectableBodyShapes)));
	
	CopyPointer(ptrbutton, element);
	selectablebodyDisplay->AddChild( element );
	
	Pointer<GUIListBox> list = new GUIListBox();
	gameEditor->lstSelectableBodyShapes = list;
	list->Dimensions(Maths::Point<unsigned int>(200, 130));
	list->Location(Maths::Point<unsigned int>(0,0));
	
	CopyPointer(list, element);
	selectablebodyDisplay->AddChild( element );

	CopyPointer(selectablebodyDisplay, element);
	gui->AddElement(element);
	
	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(selectablebodyDisplay, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(selectablebodyDisplay, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(selectablebodyDisplay, &GUIWindow::ReceiveEvent) ));
}
void GUIRigidBodyWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> rigidbodyDisplay = new GUIWindow();
	gameEditor->wndRigidBodyDisplay = rigidbodyDisplay;
	rigidbodyDisplay->Visible(false);
	rigidbodyDisplay->Dimensions(Maths::Point<unsigned int>(200, 130));
	rigidbodyDisplay->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	rigidbodyDisplay->FontColor(0xFF00FF00);
	rigidbodyDisplay->Title(std::string("RigidBody Shapes"));
	
	Pointer<GUIButton> ptrbutton = new GUIButton();
	gameEditor->btnRigidBodyDelete = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(2, 0));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Delete"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::DeleteRigidBodyShape)));
	
	CopyPointer(ptrbutton, element);
	rigidbodyDisplay->AddChild( element );
	
	ptrbutton = new GUIButton();
	gameEditor->btnRigidBodyCancel = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(64, 0));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Cancel"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::HideRigidBodyShapes)));
	
	CopyPointer(ptrbutton, element);
	rigidbodyDisplay->AddChild( element );
	
	ptrbutton = new GUIButton();
	gameEditor->btnRigidBodyDeleteAll = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(126, 0));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Delete All"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::DeleteAllRigidBodyShapes)));
	
	CopyPointer(ptrbutton, element);
	rigidbodyDisplay->AddChild( element );
	
	Pointer<GUIListBox> list = new GUIListBox();
	gameEditor->lstRigidBodyShapes = list;
	list->Dimensions(Maths::Point<unsigned int>(200, 130));
	list->Location(Maths::Point<unsigned int>(0,0));
	
	CopyPointer(list, element);
	rigidbodyDisplay->AddChild( element );

	CopyPointer(rigidbodyDisplay, element);
	gui->AddElement(element);
	
	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(rigidbodyDisplay, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(rigidbodyDisplay, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(rigidbodyDisplay, &GUIWindow::ReceiveEvent) ));
}
void GUISceneGraphWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> sceneGraphWindow = new GUIWindow();
	gameEditor->wndSceneGraphDisplay = sceneGraphWindow;
	sceneGraphWindow->Dimensions(Maths::Point<unsigned int>(200, 320));
	sceneGraphWindow->Location(Maths::Point<unsigned int>(Renderer->getWindowWidth()/2 - 100, Renderer->getWindowHeight()/2 - 140));
	sceneGraphWindow->FontColor(0xFF00FF00);
	sceneGraphWindow->Visible(false);
	sceneGraphWindow->Title(std::string("Scene Graph"));

	Pointer<GUITree> nodeTree = new GUITree();
	gameEditor->treSceneGraphNodes = nodeTree;
	nodeTree->Location(Maths::Point<unsigned int>(0, 0));
	nodeTree->FontColor(0xFF000000);
	nodeTree->Title(std::string("Root"));
	nodeTree->OnChangeSelected(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::OnSceneNodeChangeSelected)));
	nodeTree->OnDragDropSelected(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::DragDropSceneGraph)));
	CopyPointer(nodeTree, element);
	sceneGraphWindow->AddChild(element);
		
	Pointer<GUIButton> button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(2, 278));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Delete Node"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::DeleteSceneGraphNode)));
	CopyPointer(button, element);
	sceneGraphWindow->AddChild( element );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(86, 278));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Close"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::HideSceneGraph)));
	CopyPointer(button, element);
	sceneGraphWindow->AddChild( element );
	

	CopyPointer(sceneGraphWindow, element);
	gui->AddElement(element);	
	
	Renderer->getWindow()->RegisterHandler("OnMouseMoveEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(sceneGraphWindow, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseLeftDownEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(sceneGraphWindow, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseLeftUpEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(sceneGraphWindow, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(sceneGraphWindow, &GUIWindow::ReceiveEvent) ));
}
void GUIEntityListWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> entityListWindow = new GUIWindow();
	gameEditor->wndEntityList = entityListWindow;
	entityListWindow->Visible(false);
	entityListWindow->Dimensions(Maths::Point<unsigned int>(200, 130));
	entityListWindow->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	entityListWindow->FontColor(0xFF00FF00);
	entityListWindow->Title(std::string("Entites..."));
	
	Pointer<GUIButton> ptrbutton = new GUIButton();
	gameEditor->btnEntityDelete = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(2, 0));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Delete"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::DeleteEntityByName)));
	
	CopyPointer(ptrbutton, element);
	entityListWindow->AddChild( element );
	
	ptrbutton = new GUIButton();
	gameEditor->btnEntityDeleteCancel = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(64, 0));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Cancel"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::HideEntityWindow)));
	
	CopyPointer(ptrbutton, element);
	entityListWindow->AddChild( element );
	
	Pointer<GUIListBox> list = new GUIListBox();
	gameEditor->lstEntityNames = list;
	list->OnSelectedChangedFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::OnEntityListSelectedChange)));
	list->Location(Maths::Point<unsigned int>(0,0));
	list->Dimensions(Maths::Point<unsigned int>(20, 130));
	
	CopyPointer(list, element);
	entityListWindow->AddChild( element );

	CopyPointer(entityListWindow, element);
	gui->AddElement(element);
	
	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(entityListWindow, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(entityListWindow, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(entityListWindow, &GUIWindow::ReceiveEvent) ));
}
void GUICreateWorldWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> createWorld = new GUIWindow();
	gameEditor->wndCreateWorld = createWorld;
	createWorld->Visible(false);
	createWorld->Dimensions(Maths::Point<unsigned int>(200, 130));
	createWorld->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	createWorld->FontColor(0xFF00FF00);
	createWorld->Title(std::string("Create World"));
	createWorld->EnterFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CreateWorld)));
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtWorldName = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("World Name..."));
	CopyPointer(textbox, element);
	createWorld->AddChild( element );
	
	Pointer<GUIButton> button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(2, 90));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Create World"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CreateWorld)));
	CopyPointer(button, element);
	createWorld->AddChild( element );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(86, 90));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Cancel"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CancelCreateWorld)));
	CopyPointer(button, element);
	createWorld->AddChild( element );
	
	CopyPointer(createWorld, element);
	gui->AddElement(element);

	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(createWorld, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(createWorld, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(createWorld, &GUIWindow::ReceiveEvent) ));
}
void GUISetWorldWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> setWorld = new GUIWindow();
	gameEditor->wndSetToWorld = setWorld;
	setWorld->Visible(false);
	setWorld->Dimensions(Maths::Point<unsigned int>(200, 130));
	setWorld->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	setWorld->FontColor(0xFF00FF00);
	setWorld->Title(std::string("Set World"));
	setWorld->EnterFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SetWorld)));
	
	Pointer<GUITextbox> textbox = new GUITextbox();
	gameEditor->txtSetToWorldName = textbox;
	textbox->Dimensions(Maths::Point<unsigned int>(196, 20));
	textbox->Location(Maths::Point<unsigned int>(2, 2));
	textbox->FontColor(0xFFFF0000);
	textbox->DefaultText(std::string("World Name..."));
	CopyPointer(textbox, element);
	setWorld->AddChild( element );
	
	Pointer<GUIButton> button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(2, 90));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Set World"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::SetWorld)));
	CopyPointer(button, element);
	setWorld->AddChild( element );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(86, 90));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Cancel"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::CancelSetWorld)));
	CopyPointer(button, element);
	setWorld->AddChild( element );
	
	CopyPointer(setWorld, element);
	gui->AddElement(element);

	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(setWorld, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(setWorld, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(setWorld, &GUIWindow::ReceiveEvent) ));
}

void GUIAIWindowConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<IGUIElement> element;
	Pointer<GUIWindow> aiWindow = new GUIWindow();
	gameEditor->wndAIWindow = aiWindow;
	aiWindow->Visible(false);
	aiWindow->Dimensions(Maths::Point<unsigned int>(200, 65));
	aiWindow->Location(Maths::Point<unsigned int>((Renderer->getWindowWidth()/2) - 100, (Renderer->getWindowHeight()/2)-40));	// Center
	aiWindow->FontColor(0xFF00FF00);
	aiWindow->Title(std::string("AI Window..."));
	
	Pointer<GUIButton> ptrbutton = new GUIButton();
	gameEditor->btnAIDelete = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(2, 22));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Delete"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::DeleteAIBehavior)));
	
	CopyPointer(ptrbutton, element);
	aiWindow->AddChild( element );
	
	ptrbutton = new GUIButton();
	gameEditor->btnAIDeleteCancel = ptrbutton;
	ptrbutton->Location(Maths::Point<unsigned int>(64, 22));
	ptrbutton->Dimensions(Maths::Point<unsigned int>(60, 20));
	ptrbutton->FontColor(0xFFFF0000);
	ptrbutton->Text(std::string("Cancel"));
	ptrbutton->BackgroundColor(0xFFCCCCCC);
	ptrbutton->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::HideAIWindow)));
	CopyPointer(ptrbutton, element);
	aiWindow->AddChild( element );
	
	Pointer<GUILabel> label = new GUILabel();
	gameEditor->lblBehaviorType = label;
	label->Location(Maths::Point<unsigned int>(0,0));
	label->Dimensions(Maths::Point<unsigned int>(20, 20));
	CopyPointer(label, element);
	aiWindow->AddChild( element );

	CopyPointer(aiWindow, element);
	gui->AddElement(element);
	
	Renderer->getWindow()->RegisterHandler("OnMouseDownLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(aiWindow, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseUpLeftEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(aiWindow, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(aiWindow, &GUIWindow::ReceiveEvent) ));
}
void GUIAIToolboxConstruction( GUINode* gui, GameEditorGUI* gameEditor )
{
	Pointer<GUIWindow> toolbox = new GUIWindow();
	gameEditor->wndAIToolbox = toolbox;
	Pointer<IGUIElement> element;
	toolbox->Dimensions(Maths::Point<unsigned int>(TOOLBOX_DIMENSIONS));
	toolbox->Location(Maths::Point<unsigned int>(TOOLBOX_LOCATION));
	toolbox->FontColor(0xFF00FF00);
	toolbox->Title(std::string("AI Toolbox"));
	toolbox->Visible(false);

	GUIButton* button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 2));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Add Destination"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ToggleAddDestination)));
	toolbox->AddChild( button );
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 22));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Set World"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowSetWorldWindow)));
	toolbox->AddChild( button );
	
	
	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 42));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("Create World"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::ShowCreateWorldWindow)));
	toolbox->AddChild( button );

	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 72));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("AI:Minion Behavior"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::AddMinionBehavior)));
	toolbox->AddChild( button );

	button = new GUIButton();
	button->Dimensions(Maths::Point<unsigned int>(80, 20));
	button->Location(Maths::Point<unsigned int>(10, 92));
	button->FontColor(0xFFFF0000);
	button->Text(std::string("AI:Spawn Behavior"));
	button->BackgroundColor(0xFFCCCCCC);
	button->ClickFunction(Pointer<Functor>(new CFunctor<GameEditorGUI>(gameEditor, &GameEditorGUI::AddSpawnPointBehavior)));
	toolbox->AddChild( button );

	CopyPointer(toolbox, element);
	gui->AddElement(element);
	
	Renderer->getWindow()->RegisterHandler("OnMouseLeftDownEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(toolbox, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnMouseLeftUpEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(toolbox, &GUIWindow::ReceiveEvent) ));
	Renderer->getWindow()->RegisterHandler("OnKeyPressEvent", Pointer<EventHandler>( new CEventHandler<GUIWindow>(toolbox, &GUIWindow::ReceiveEvent) ));
}